package com.william.springsecurity.mapper;

import com.william.springsecurity.pojo.SysPermission;
import com.william.springsecurity.pojo.SysRole;
import com.william.springsecurity.pojo.SysUser;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserMapper{

//    @Select("select * from sys_user where username = #{username}")
//    @Results({
//            @Result(id = true, property = "id", column = "id"),
//            @Result(property = "roles", column = "id", javaType = List.class,
//                many = @Many(select = "com.william.springsecurity.mapper.RoleMapper.findByUid"))
//    })
//    SysUser findByName(String username);

    @Select("select * from sys_user where username = #{username}")
    SysUser findByName(String username);

    List<SysRole> getUserRoles(Long userId);
    List<SysPermission> getUserPermission(Long userId);
}
